/* libfake437 - a library for the rendering of code page 437 `graphics'
 * Copyright (C) 2008, 2009, 2010, 2011 Jack Kelly <endgame.dos@gmail.com>
 *
 * This library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 ** @node Data Types
 ** @chapter Data Types
 **/

#ifndef FAKE437_TYPES_H
#define FAKE437_TYPES_H

#ifdef __cplusplus
extern "C"{
#endif

/**
 ** @defvr{Constant} F437_DEFAULT_WIDTH
 ** @defvrx{Constant} F437_DEFAULT_HEIGHT
 **
 ** Define the default width and height of the screen, in characters.
 **
 ** @end defvr
 **/
#define F437_DEFAULT_WIDTH 80
#define F437_DEFAULT_HEIGHT 25

/**
 ** @deftp{Data Type} F437Color
 **
 ** @code{F437Color} is an enumeration of the available rendering colors.
 **
 ** @end deftp
 **
 ** @deftp{F437Color} F437_COLOR_BLACK
 ** @deftpx{F437Color} F437_COLOR_BLUE
 ** @deftpx{F437Color} F437_COLOR_GREEN
 ** @deftpx{F437Color} F437_COLOR_CYAN
 ** @deftpx{F437Color} F437_COLOR_RED
 ** @deftpx{F437Color} F437_COLOR_MAGENTA
 ** @deftpx{F437Color} F437_COLOR_YELLOW
 ** @deftpx{F437Color} F437_COLOR_WHITE
 **
 ** These are the dim colors. Note that @code{F437_COLOR_YELLOW} renders
 ** as brown and @code{F437_COLOR_WHITE} renders as grey.
 **
 ** @end deftp
 **
 ** @deftp{F437Color} F437_COLOR_BBLACK
 ** @deftpx{F437Color} F437_COLOR_BBLUE
 ** @deftpx{F437Color} F437_COLOR_BGREEN
 ** @deftpx{F437Color} F437_COLOR_BCYAN
 ** @deftpx{F437Color} F437_COLOR_BRED
 ** @deftpx{F437Color} F437_COLOR_BMAGENTA
 ** @deftpx{F437Color} F437_COLOR_BYELLOW
 ** @deftpx{F437Color} F437_COLOR_BWHITE
 **
 ** These are brighter versions of the above. @code{F437_COLOR_BYELLOW} is
 ** actually yellow, and @code{F437_COLOR_BBLACK} is a darker grey than
 ** @code{F437_COLOR_WHITE}.
 **
 ** @end deftp
 **
 ** @deftp {F437Color} F437_COLOR_TRANSPARENT
 **
 ** Transparent output.
 **
 ** @end deftp
 **/
typedef enum {
  F437_COLOR_BLACK,
  F437_COLOR_BLUE,
  F437_COLOR_GREEN,
  F437_COLOR_CYAN,
  F437_COLOR_RED,
  F437_COLOR_MAGENTA,
  F437_COLOR_YELLOW,
  F437_COLOR_WHITE,
  F437_COLOR_BBLACK,
  F437_COLOR_BBLUE,
  F437_COLOR_BGREEN,
  F437_COLOR_BCYAN,
  F437_COLOR_BRED,
  F437_COLOR_BMAGENTA,
  F437_COLOR_BYELLOW,
  F437_COLOR_BWHITE,
  F437_COLOR_TRANSPARENT,
  F437_NUM_COLORS
} F437Color;

/**
 ** @deftp{Data Type} F437Font
 **
 ** A @code{F437Font} defines how the character set is
 ** rendered. @var{char_width} is the width of an individual character
 ** in pixels. @var{char_height} is the height of each individual
 ** character. @var{chars} points to an array of length 256 *
 ** @var{char_width} * @var{char_height} representing each character
 ** in row-major order. The @code{F437Font} does not take ownership of
 ** this pointer.
 **
 ** @deftypeivar F437Font int char_width
 ** @end deftypeivar
 **
 ** @deftypeivar F437Font int char_height
 ** @end deftypeivar
 **
 ** @deftypeivar F437Font {const Uint8*} data
 ** @end deftypeivar
 **
 ** @end deftp
 **/
typedef struct {
  int char_width;
  int char_height;
  const Uint8* chars; /* not owned */
} F437Font;

/**
 ** @deftp {F437FontName} F437_FONT_8x8
 **
 ** 8x8 characters. This was a CGA font.
 **
 ** @end deftp
 **
 ** @deftp {F437FontName} F437_FONT_8x8_THIN
 **
 ** 8x8 characters, thin style. This was an uncommon CGA font.
 **
 ** @end deftp
 **
 ** @deftp {F437FontName} F437_FONT_8x14
 **
 ** 8x14 characters. This is the classic DOS look.
 **
 ** @end deftp
 **/
typedef enum {
  F437_FONT_8x8,
  F437_FONT_8x8_THIN,
  F437_FONT_8x14
} F437FontName;

/**
 ** @deftp{Data Type} F437Surface
 **
 ** A @code{F437Surface} encapsulates a @code{SDL_Surface} to provide
 ** a character-oriented interface, instead of a pixel-oriented
 ** one. Clients should only ever read from the struct's fields, but
 ** never write to them. Use the supplied API instead.
 **
 ** @deftypeivar F437Surface SDL_Surface* surface
 ** The surface to be written upon.
 ** @end deftypeivar
 **
 ** @deftypeivar F437Surface {const F437Font*} font
 ** The font to be used when writing.
 ** @end deftypeivar
 **
 ** @deftypeivar F437Surface int scale
 ** An integer multiplier on the size of the glyphs.
 ** @end deftypeivar
 **
 ** @deftypeivar F437Surface int left
 ** Horizontal offset in pixels.
 ** @end deftypeivar
 **
 ** @deftypeivar F437Surface int top
 ** Vertical offset in pixels.
 ** @end deftypeivar
 **
 ** @deftypeivar F437Surface int width
 ** Width in characters.
 ** @end deftypeivar
 **
 ** @deftypeivar F437Surface int height
 ** Height in characters.
 ** @end deftypeivar
 **
 ** @deftypeivar F437Surface int cursor_x
 ** X position of the insertion point.
 ** @end deftypeivar
 **
 ** @deftypeivar F437Surface int cursor_y
 ** Y position of the insertion point.
 ** @end deftypeivar
 **
 ** @deftypeivar F437Surface {const SDL_Color*} fg
 ** Foreground colour.
 ** @end deftypeivar
 **
 ** @deftypeivar F437Surface {const SDL_Color*} bg
 ** Background colour.
 ** @end deftypeivar
 **
 ** @end deftp
 **/
typedef struct {
  SDL_Surface* surface; /* not owned */
  const F437Font* font; /* not owned */
  int scale;
  int left;
  int top;
  int width;
  int height;
  int cursor_x;
  int cursor_y;
  const SDL_Color* fg;
  const SDL_Color* bg;
} F437Surface;

#ifdef __cplusplus
}
#endif

#endif
